package com.sky.mapper;

import com.sky.entity.SetmealDish;
import com.sky.vo.DishItemVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {
    /*
    * 保存套餐和菜品的关联关系
    * */
    void insertBatch(List<SetmealDish> setmealDishes,@Param("sId") Long setmealId);

    /*
     * 根据套餐id查询套餐包含的菜品
     * */
    @Select("select copies,dish.name, dish.image, dish.description from setmeal_dish left join dish on dish_id = dish.id " +
            "where setmeal_id = #{id}")
    List<DishItemVO> selectBySetmealId(Long id);

    /*
    * 根据套餐id查询套餐包含的菜品返回SetmealDish的集合
    * */
    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> selectBySetmealIdWithSetmealDish(Long id);

    /*
    * 根据套餐id批量删除关联菜品数据
    * */

    void deleteBySetmealIds(List<Long> ids);

    /*
    * 统计菜品id在ids中且菜品在套餐中的菜品数量
    * */
    Integer countBySetmealId(@Param("ids") List<Long> ids);

    /*
    * 根据套餐id查询套餐中未起售菜品的数量
    * */
    Integer countNotOnSaleBySetmealId(Long setmealId);

    /*
     * 根据菜品id查询起售套餐中有当前菜品的数目
     * */
    Integer countDishInSetmealOnSale(Long id);
}
